package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.WemediaDto;
import com.heima.model.wemedia.pojos.Channel;
import com.heima.wemedia.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 嘉德罗斯
 * @date 2021/11/29
 */
@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelDto dto){
        return channelService.find(dto);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WemediaDto dto){
        return channelService.update(dto);
    }

    @PostMapping("/save")
    private ResponseResult save(@RequestBody WemediaDto dto){
        return channelService.save(dto);
    }

    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return channelService .del(id);
    }
}
